<?php
	$cs=Yii::app()->clientScript;
	$baseUrl=$this->module->assetsUrl;
	$cs->registerScriptFile($baseUrl.'/js/category-edit.js',CClientScript::POS_END);
    $registerScript="var sUrl='".$this->createUrl('category/ajaxTemplateList')."';";
    $registerScript.="var sType='';";
    $registerScript.="var sUploadUrl='".$this->createUrl('attachment/upload')."';";
	Yii::app()->getClientScript()->registerScript('registerScript',$registerScript,CClientScript::POS_HEAD);
?>
<div class="row">
    <div class="button-container mb10">
    	<?php echo Yii::app()->user->checkAccess('category|add')?CHtml::link('添加栏目',$this->createUrl('category/add' ,array('cate_type'=>1,'pid'=>$pid)),array('class'=>'button')):'';?>
        <?php echo Yii::app()->user->checkAccess('category|add')?CHtml::link('添加单页面',$this->createUrl('category/add' ,array('cate_type'=>2,'pid'=>$pid)),array('class'=>'button')):'';?>
        <?php echo Yii::app()->user->checkAccess('category|add')?CHtml::link('添加外部栏目',$this->createUrl('category/add' ,array('cate_type'=>3,'pid'=>$pid)),array('class'=>'button button-success')):'';?>
    
    </div>
    <div id="tab">
        <ul>
          <li class="bui-tab-panel-item active"><a href="#">基本设置</a></li>
        </ul>
    </div>
    <?php $form=$this->beginWidget('CActiveForm', array(
        'id'=>'category-_form-form',
        'enableAjaxValidation'=>false,
        'enableClientValidation'=>false,
        'clientOptions'=>array(  
            'validateOnSubmit'=>false,  
         ),
         'htmlOptions'=>array('class'=>'form-horizontal')
    )); ?>
    <div id="panel" class="" style="width: 100%; border:1px solid #ccc;">
        <div id="p1" class="mt10">
            <div class="control-group">
                <label class="control-label"><?php echo $this->_attributeLabels['parent_id'] ?><span class="required">*</span>：</label>
                <div class="controls">
                    <select name="AdminCategory[parent_id]" class="input-normal">
                    <option value="0">顶级栏目</option>
                    <?php 
                    $menuData = AdminCategory::getCategoryData();
                    $tree = new Tree($menuData);
                    $tree->icon = array('&nbsp;│ ','&nbsp;├─ ','&nbsp;└─ ');
                    $tree->nbsp = '&nbsp;';
                    $str="<option value='\$id' \$selected>\$spacer\$cate_name</option>";
                    $categorys = $tree->get_tree(0, $str, $pid);
                    echo $categorys;
                    ?>
                    </select>     
                  <?php //echo $form->textField($this->oModel,'model_id' ,array('data-rules'=>"{required:true}",'data-messages'=>"{required:'模型名称不能为空'}",'class'=>'input-large')); ?>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"><?php echo $this->_attributeLabels['cate_name'] ?><span class="required">*</span>：</label>
                <div class="controls">
                  <?php echo $form->textField($this->oModel,'cate_name' ,array('data-rules'=>"{required:true}",'data-messages'=>"{required:'栏目名称不能为空'}",'class'=>'input-normal')); ?>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"><?php echo $this->_attributeLabels['cate_image'] ?>：</label>
                <div class="controls control-row-auto">
                    <div id="J_Uploader"></div>
                    <div class="category-image">
                    <?php
                        echo isset($this->oModel->cate_image) ?  "<img src='".$this->oModel->cate_image."' width='120' />" : '';
                    ?>
                    </div>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"><?php echo $this->_attributeLabels['url'] ?>：</label>
                <div class="controls">
                  <input type="hidden" value="<?php echo $iCateType; ?>" name="AdminCategory[cate_type]" />   
                  <?php echo $form->textField($this->oModel,'url' ,array('class'=>'input-large')); ?>
                </div>
            </div>
        </div>
    </div>
    <div class="mt10">
        <input type="submit" value="提交" class="button" />
    </div>
    <?php $this->endWidget(); ?>
</div>